#!/bin/bash
# btrfs_balance start <dev> <options> 
# btrfs_balance status <dev>
# btrfs_balance cancel <dev> 

case "$1" in
'start')
  options=$3
  [[ -z "${options// }" ]] && options="--full-balance"
  exec /sbin/btrfs balance start $options $2 &>/dev/null &
;;
'status')
  /sbin/btrfs balance status $2
  /sbin/btrfs balance status $2 | grep -q running
;;
'cancel')
  /sbin/btrfs balance cancel $2 &>/dev/null
;;
esac
